package com.dlc.felear.xiaoensale.helper;

import android.content.Context;
import android.text.TextUtils;

import com.dlc.felear.xiaoensale.constant.Constant;

public class SerialManager {
    private static Session session;
    private static String SERIAL_PORT_HOT = "";
    private static String SERIAL_PORT_LOCK = "";
    private static String SERIAL_PORT_MUTIL_LOCK = "";
    private static String SERIAL_PORT_WEIGHT = "";
    private static String SERIAL_PORT_LOCK_WEIGHT = "";
    private static String SERIAL_PORT_RFID = "";

    public static void init(Context context) {
        session=Session.getSession();
    }

    public static String getControlLockSerialPort() {
        if (TextUtils.isEmpty(SERIAL_PORT_LOCK)) {
            SERIAL_PORT_LOCK = session.getString(Constant.SERIAL_PORT_LOCK, "/dev/ttyS1");
        }
        return SERIAL_PORT_LOCK;
    }
//    public static String getControlHotSerialPort() {
//        if (TextUtils.isEmpty(SERIAL_PORT_HOT)) {
//            SERIAL_PORT_HOT = session.getString(Constant.SERIAL_PORT_HOT, "/dev/ttyS0");
//        }
//        return SERIAL_PORT_HOT;
//    }

    public static String getControlMutilLockSerialPort() {
        if (TextUtils.isEmpty(SERIAL_PORT_MUTIL_LOCK)) {
            SERIAL_PORT_MUTIL_LOCK = session.getString(Constant.SERIAL_PORT_MUTIL_LOCK, "未定义");
        }
        return SERIAL_PORT_MUTIL_LOCK;
    }

    public static String getControlWeightSerialPort() {
        if (TextUtils.isEmpty(SERIAL_PORT_WEIGHT)) {
            SERIAL_PORT_WEIGHT = session.getString(Constant.SERIAL_PORT_WEIGHT, "/dev/ttyS0");
        }
        return SERIAL_PORT_WEIGHT;
    }

    public static String getControlLockWeightSerialPort() {
        if (TextUtils.isEmpty(SERIAL_PORT_LOCK_WEIGHT)) {
            SERIAL_PORT_LOCK_WEIGHT = session.getString(Constant.SERIAL_PORT_LOCK_WEIGHT, "/dev/ttysWK0");
        }
        return SERIAL_PORT_LOCK_WEIGHT;
    }

    public static String getControlRfidSerialPort() {
        if (TextUtils.isEmpty(SERIAL_PORT_RFID)) {
            SERIAL_PORT_RFID = session.getString(Constant.SERIAL_PORT_RFID, "/dev/ttyS2");
        }
        return SERIAL_PORT_RFID;
    }

}
